﻿//这个类主要用于玫瑰线绘制
//author 夏天的树人
//vesion 1.0

package org.summerTree.graphics
{

	import flash.display.Sprite;
	import flash.geom.Point;
	public class Rose extends Base 
	{
		public static  const RAD:String="rad";
		public static  const ANGLE:String="angle";
		public static  const ANGLE2:String="angle2";
		//private var LineColor:uint=0x000000;//默认是黑色
		public function Rose()
		{
			this.graphics.moveTo(0,0);
		}
		
		override public function clone():*
		{
			return new Rose();
		}
		//创建2D的玫瑰线
		public function CreatRose(r:Number,num:Number,type:String="rad",lens:int=1,count:int=360):void
		{
			this.graphics.lineStyle(0,color);
			var rad:Number;
			if (type == Rose.RAD)
			{
				rad=lens * Math.PI / 180;//角度  
			}
			else if (type == Rose.ANGLE)
			{
				rad=lens;//角度
			}
			else if (type == Rose.ANGLE2)
			{
				rad=lens * 180 / Math.PI;
			}//角度  
			for (var j:int=0; j <= count; j++)
			{
				var len:Number=r * Math.sin(num * rad * j);
				var point:Point=Point.polar(len,rad * j);
				drawPoint(point);
			}
		}
		//绘制玫瑰线
		public function drawRose(r:Number,angle:Number,num:int):void
		{
			var len:Number=r * Math.sin(num * angle);
			var point:Point=Point.polar(len,angle);
			drawPoint(point);
		}
		//描点
		private function drawPoint(point:Point):void
		{
			
			this.graphics.lineTo(point.x,point.y);
		}
		////设置颜色
//		public function set color(value:uint):void
//		{
//			this.LineColor=value;
//		}
//		//获取颜色
//		public function get color():uint
//		{
//			return this.LineColor;
//		}
		//清除图像
		//public function clear():void
//		{
//			this.graphics.clear();
//		}
	}
}